package com.jiedeng.controller.index;

import com.jiedeng.controller.Rst;
import com.jiedeng.dao.ISysModuleRepository;
import com.jiedeng.dao.ISysRuleRepository;
import com.jiedeng.model.SysRule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 权限管理
 *
 * @author zhouyb
 */
@RestController
@RequestMapping("/jurisdictionit")
public class JurisdictionController {
    @Autowired
    ISysModuleRepository sysModuleRepository;

    @Autowired
    ISysRuleRepository ruleRepository;

    /**
     * 判断权限
     *
     * @param byname  名字
     * @param postId  岗位id
     * @param corpId 单位id
     * @return
     */
    @RequestMapping("checkModuleRule")
    public Rst checkModuleRule(String byname, Long postId, Long corpId) {
        Rst rst = new Rst();
        List<SysRule> sysRuleList = ruleRepository.checkRule(byname, postId, corpId);
        rst.setResultCode(0);
        if (sysRuleList != null && sysRuleList.size() > 0) {
            rst.setMsg("OK");
        } else {
            rst.setMsg("NO");
        }

        return rst;
    }
}
